using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Identity;
using UserManagementService.Common.DTOs;

namespace UserManagementService.Users;

/// <summary>
/// 扩展用户仓储服务接口
/// </summary>
public interface IExtendedUserRepository
{
    /// <summary>
    /// 根据用户名获取用户（包含扩展信息）
    /// </summary>
    Task<IdentityUser?> FindByNormalizedUserNameAsync(
        string normalizedUserName,
        bool includeDetails = true,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据邮箱获取用户（包含扩展信息）
    /// </summary>
    Task<IdentityUser?> FindByNormalizedEmailAsync(
        string normalizedEmail,
        bool includeDetails = true,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据手机号获取用户
    /// </summary>
    Task<IdentityUser?> FindByPhoneNumberAsync(
        string phoneNumber,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取指定组织下的用户列表
    /// </summary>
    Task<List<IdentityUser>> GetUsersInOrganizationAsync(
        Guid organizationId,
        bool includeDetails = false,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取指定角色的用户列表
    /// </summary>
    Task<List<IdentityUser>> GetUsersInRoleAsync(
        string roleName,
        bool includeDetails = false,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取活跃用户统计
    /// </summary>
    Task<UserStatisticsDto> GetUserStatisticsAsync(
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 批量更新用户状态
    /// </summary>
    Task<int> BatchUpdateUserStatusAsync(
        List<Guid> userIds,
        UserStatus status,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 搜索用户
    /// </summary>
    Task<List<IdentityUser>> SearchUsersAsync(
        string keyword,
        int maxResultCount = 10,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取用户权限
    /// </summary>
    Task<List<string>> GetUserPermissionsAsync(
        Guid userId,
        CancellationToken cancellationToken = default);
}